
import { PrismaClient } from '@prisma/client'

const prisma = new PrismaClient()
import { PageParams } from '@/types';
import { EditMoonCard } from './EditMoonCard';
import { MoonCardList } from './MoonCardList';



export default async function Page({searchParams}: { searchParams: PageParams }) {
  console.log('params', searchParams)
  const { offset = 1, limit = 10 } = searchParams;

  const moonCards = await prisma.moonCard.findMany({
    take: limit - 0,
    skip: (offset - 1) * limit
  })
  // 获取总数
  const total = await prisma.moonCard.count()

  return (
    <div className="text-[#333] p-4">
      <EditMoonCard type='add' />
      <MoonCardList moonCards={moonCards} total={total} />
    </div>
  )
}